Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
Getting "document is not defined" in JS

I'm trying to build a simple Blackjack game, and everything was going well, until I started getting the error "document is not defined"... I'm using VS Code with Node, so I just write in the terminal "node index.js" and it always works, however for some reason it's not working now.

Here's the error:

let messageEl = document.getElementById("message-el");
                ^

ReferenceError: document is not defined
    at Object.<anonymous> (C:\Users\draven\Desktop\JAVASCRIPT\Blackjack\index.js:9:17)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

node runs in a server environment, which doesn't have any document or window because it is not a browser environment.

about 4 years ago · Juan Pablo Isaza Denunciar

0

document is a web browser concept, it doesn't exist in the node runtime.

Check out this answer for the a great explination: Document in node

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda